package com.furentech.iotserver.fa.sinopec.sinopec_processor;


import com.furentech.iotserver.fa.server.ChannelUtil;
import com.furentech.iotserver.fa.sinopec.SinopecFunCode;
import io.netty.channel.Channel;
import org.springframework.stereotype.Component;


@Component
public class ReqSignIn_Processor extends SinopecProcessorBase{
    @Override
    String actualGetJsonString(byte[] buf) {
        return null;
    }

    @Override
    String actualGetReadableString(byte[] buf) {
        return "加油机签到";
    }

    @Override
    byte[] actualGetResponse(byte[] buf, Channel channel) {
        byte[] tempByteBuf = new byte[61];
        tempByteBuf[0] = SinopecFunCode.Resp_Sign_in;
        System.arraycopy(buf, 1, tempByteBuf, 1, 4);
        tempByteBuf[5] = buf[5];
        tempByteBuf[6] = 0x00;
        System.arraycopy(buf, 66, tempByteBuf, 57, 4);

        Byte[] tempBytes = new Byte[tempByteBuf.length];
        for (int i = 0; i < tempByteBuf.length; i++) {
            tempBytes[i]=tempByteBuf[i];
        }
        ChannelUtil.setReqSignInRespBuf(channel, tempBytes);
        ChannelUtil.setReqSignInFlag(channel, true);


        byte[] resByteBuf = new byte[4];

        resByteBuf[0] = SinopecFunCode.CMD_ACK;
        resByteBuf[1] = buf[0];
        resByteBuf[2] = buf[5];
        resByteBuf[3] = 0x02;

        return resByteBuf;

    }
}
